#include "RaceTrack.h"

RaceTrack::RaceTrack(int t,float l,Ponto3f left, Ponto3f right){
     type = t;
     length = l;
     switch(t){
           case 1:
                leftInitial = left;
                rightInitial = right;
                loadStructure(t); //reta
                break;
           case 2:
                loadStructure(t);
                break;
           case 3:
                loadStructure(t);
                break;
     }
             
                         
}


void RaceTrack::loadStructure(int t){
     switch(t){
           case 1: //reta
                structure = (Ponto3f*)malloc(sizeof(Ponto3f)*2);
                structure[0] = (Ponto3f){-3.0,0.0,-leftInitial.z};
                structure[1] = (Ponto3f){-3.0,0.0,-(leftInitial.z + length)};
                leftFinal = (Ponto3f){-3.0,0.0,(leftInitial.z + length)};
                rightFinal = (Ponto3f){3.0,0.0,(rightInitial.z + length)};
                break;
           case 2:
                
                break;
           case 3:
                
                break;           
                  
     }
     
}
void RaceTrack::draw(){
     switch(type){
           case 1: //reta
                glBegin(GL_POLYGON);
                    glVertex3f(-3.0,0.0,-leftInitial.z);
                    glVertex3f(-3.0,0.0,-(leftInitial.z + length));
                    glVertex3f(3.0,0.0,-(rightInitial.z + length));
                    glVertex3f(3.0,0.0,-rightInitial.z);  
                glEnd();
                break;
           case 2: //curva pra esquerda

                break;
           case 3: //curva pra direita

                break;
     }
     
}
